package ar.com.jendrix.login.mail;

import java.io.Serializable;

import ar.com.jendrix.common.util.Comparator;

@SuppressWarnings("serial")
public final class MailMessage implements Serializable {

	private String to;
	private String subject;
	private StringBuilder message;

	public MailMessage(String to, String subject, String message) {
		this.to = to;
		this.subject = subject;
		setMessage(message);
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getMessage() {
		return message != null ? message.toString() : "";
	}

	public void setMessage(String message) {
		this.message = new StringBuilder(message);
	}

	public void addMessage(String text) {
		if (message == null) {
			message = new StringBuilder();
		}
		message.append(text);
	}

	public String getPersonalName() {
		String personalName = null;
		if (!Comparator.isEmpty(getTo())) {
			personalName = getTo().split("@")[0];
			// if (mailProvider.indexOf(".") > 0) {
			// mailProvider = mailProvider.substring(0,mailProvider.indexOf("."));
			// }
		}
		return personalName;
	}

}
